//
//  MyBuddy.m
//  parent
//
//  Created by 闫珍 on 15/9/11.
//  Copyright (c) 2015年 ci123. All rights reserved.
//

#import "MyBuddy.h"
#import "Tool.h"

@implementation MyBuddy

-(void)loadInfoByUsername
{
//    NSString * url = [NSString stringWithFormat:@"%@%@/uid/%@",SERVER_URL_NEW,kMyInfomartion,self.buddy.username];
//    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]
//                                         options:NSDataReadingMappedIfSafe
//                                           error:nil];
//    if (data) {
//        NSDictionary *userInfoDic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
//        NSDictionary *infoDic = [userInfoDic objectForKey:@"result"];
    NSDictionary *infoDic = [Tool getInfoById:self.buddy.username];
        _nickname = [infoDic objectForKey:@"nickname"];
        if(![[infoDic objectForKey:@"pic"] isEqual:[NSNull null]]){
            _pic = [infoDic objectForKey:@"pic"];
        }else{
            _pic = @"";
        }
        _city = [infoDic objectForKey:@"city"];
        debugLog(@"userinfo:%@",infoDic);
//    }else{
//        debugLog(@"返回数据格式不对！");
//    }
}

-(void)setInfoByDic:(NSDictionary *)info
{
    if(info){
        debugLog(@"current userinfo:%@",info);
        _nickname = [info objectForKey:@"nickname"];
        if([[info objectForKey:@"pic"] isEqual:[NSNull null]]){
            _pic = @"";
        }else{
        _pic = [info objectForKey:@"pic"];
        }
        _city = [info objectForKey:@"city"];
    }
}
@end
